﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace QLNSClient
{
    public partial class Frm_dsCoThamNien : DevExpress.XtraEditors.XtraForm
    {
        QLNSServiceReference.QLNSServiceClient sv = new QLNSServiceReference.QLNSServiceClient();
        
        
        public Frm_dsCoThamNien()
        {
            InitializeComponent();
        }

        public void LoadData()
        {
           
            
            gv_dsCoTN.DataSource = sv.getTNHT();
            gridView1.Columns[0].Caption = "Mã cán bộ";
            gridView1.Columns[1].Caption = "Mã phụ cấp thâm niên";
            gridView1.Columns[2].Caption = "Hệ số thâm niên";
            gridView1.Columns[3].Caption = "Quyết định số";
            gridView1.Columns[4].Caption="Ngày ký";
            if (gridView1.DataRowCount == 0)
            {
                MessageBox.Show("Chưa có dữ liệu!");
            }
        }

        private void Frm_dsCoThamNien_Load(object sender, EventArgs e)
        {
            LoadData();
        }

        public static string sendViewTTThamNien;
        public static bool isViewCoThamNien=false;

        private void gridView1_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e)
        {
            try
            {

                
                e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("Xem thông tin thâm niên", XemTTThamNien));
                sendViewTTThamNien = gridView1.GetFocusedRowCellValue(gridView1.Columns[0]).ToString();
                isViewCoThamNien = true;
                Frm_SAPTANGTN.isSapTangTN = false;
              
            }
            catch
            {
                MessageBox.Show("Bạn cần click phải vào đầu dòng dữ liệu!", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        
        
        private void XemTTThamNien(object sender, EventArgs e)
        {
            splashScreenManager1.ShowWaitForm();
            //Frm_CBPCTN frm = new Frm_CBPCTN();
            //DialogResult dr=frm.ShowDialog();
            //if (dr==DialogResult.Cancel)
            //{
            //    //MessageBox.Show("Form CBPCTN đã đóng");
            //    LoadData();
            //    //splashScreenManager1.CloseWaitForm();
            //}
            ////frm.Show();
            //splashScreenManager1.CloseWaitForm();

            Frm_CBPCTN frm = new Frm_CBPCTN();
            frm.capnhat = new Frm_CBPCTN.CapNhatDL(LoadData);
            frm.Show();
            splashScreenManager1.CloseWaitForm();
        }

        
        public void update()
        {
            LoadData();
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            LoadData();
        }

        
    }
}